import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:cher_flare/common/models/ly_broadcaster_model.dart';
import 'package:cher_flare/common/models/ly_user_works_model.dart';
import 'package:cher_flare/common/models/ly_works_comment_model.dart';
import 'package:cher_flare/config/config.dart';
import 'package:cher_flare/modules/login/models/ly_login_info_manager.dart';
import 'package:cher_flare/utils/size_fit.dart';
import 'package:cher_flare/utils/voice/ly_voice_player.dart';
import 'package:cher_flare/utils/voice/ly_voice_recoder.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_swiper_view/flutter_swiper_view.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:svgaplayer_flutter/player.dart';

import '../../common/widgets/ly_action_sheet_page.dart';
import '../../config/url_api.dart';
import '../../http/http_utils.dart';
import '../../utils/app_color.dart';
import '../../utils/ly_data_manager.dart';
import '../../utils/translate/ly_google_translate_manager.dart';
import 'ly_rect_swiper_pagination_builder.dart';
import 'ly_voice_recorder_page.dart';

class LYWorksDetailPage extends StatefulWidget {
  const LYWorksDetailPage({super.key});

  @override
  State<LYWorksDetailPage> createState() => _LYWorksDetailPageState();
}

class _LYWorksDetailPageState extends State<LYWorksDetailPage>
    with TickerProviderStateMixin {
  final swiperController = SwiperController();
  final textController = TextEditingController();
  final scrollview = ScrollController();

  bool isUseVoice = false;
  bool isRecordPageVisible = false;
  bool isRecording = false;
  int currentPlayIndex = -1;
  LYWorksModel? worksModel;
  LyBroadcasterModel? userModel;
  String? currentFileName;
  String translateContent = '';
  final FocusNode _focusNode = FocusNode();

  double alpha = 0;

  @override
  void initState() {
    super.initState();
    worksModel = Get.arguments['works'];
    LYVoiceRecorder().initVoice();
    LYVoicePlayer().setUpPlayerConfig();
    LYDataManager.share.searchUser(worksModel?.userId ?? '').then((value) {
      userModel = value;
      setState(() {});
    });

    scrollview.addListener(() {
      if (scrollview.offset < 0) {
        alpha = 0;
      } else {
        alpha = scrollview.offset / 207;
      }
      setState(() {});
    });
    if (Config.autoTranslate) {
      _translateButtonDidClick();
    }
  }

  void _translateButtonDidClick() async {
    if (translateContent.isNotEmpty) {
      return;
    }
    EasyLoading.show(maskType: EasyLoadingMaskType.black);
    final res = await LYTranslateManager.share
        .translate(content: worksModel?.description ?? '');
    translateContent = res;
    setState(() {});
    EasyLoading.dismiss();
  }

  void _voiceTextExchangeDidClick() async {
    if (isUseVoice == true) {
      isUseVoice = false;
    } else {
      final status = await Permission.microphone.request();
      if (status != PermissionStatus.granted) {
        EasyLoading.showToast('You have not authorised this permission.');
        return;
      }
      isUseVoice = true;
    }
    setState(() {});
  }

  void _recordButtonTapDown() async {
    isRecording = true;
    isRecordPageVisible = true;
    setState(() {});
    LYVoiceRecorder().startRecord((isFinish, path, second) {
      if (second < 1) {
        EasyLoading.showToast('The recording time cannot be less than 1s');
        return;
      }
      if (isFinish && isRecording) {
        EasyLoading.show();
        Future.delayed(const Duration(seconds: 1)).then((value) {
          List<LYWorksCommentModel> result = [];
          if (worksModel?.comments != null) {
            result.addAll(worksModel!.comments!);
          }
          final commentModel = LYWorksCommentModel();
          commentModel.type = 1;
          commentModel.isUpvote = false;
          commentModel.content = path;
          final userInfo = LYLoginInfoManager.getInstance.loginModel?.userInfo;
          commentModel.avatar = userInfo?.avatarUrl;
          commentModel.nickname = userInfo?.nickname;
          commentModel.userId = userInfo?.userId;
          commentModel.seconds = second.toInt();
          result.add(commentModel);
          worksModel?.comments = result;
          LYDataManager.share.updateLocalWorksData();
          setState(() {});
          EasyLoading.dismiss();
          Future.delayed(const Duration(milliseconds: 10)).then((value) {
            scrollview.jumpTo(scrollview.position.maxScrollExtent);
          });
        });
      }
    });
  }

  void _didFinishRecord(bool isSave) async {
    LYVoiceRecorder().stopRecorder();
  }

  void _sendButtonDidClick() {
    if (isUseVoice) {
      return;
    }
    final content = textController.text;
    if (content.isEmpty) {
      EasyLoading.showToast('comment content is empty');
      return;
    }

    _focusNode.unfocus();
    textController.text = "";
    EasyLoading.show();
    Future.delayed(const Duration(seconds: 1)).then((value) {
      List<LYWorksCommentModel> result = [];
      if (worksModel?.comments != null) {
        result.addAll(worksModel!.comments!);
      }
      final commentModel = LYWorksCommentModel();
      commentModel.type = 0;
      commentModel.isUpvote = false;
      commentModel.content = content;
      final userInfo = LYLoginInfoManager.getInstance.loginModel?.userInfo;
      commentModel.avatar = userInfo?.avatarUrl;
      commentModel.nickname = userInfo?.nickname;
      commentModel.userId = userInfo?.userId;
      result.add(commentModel);
      worksModel?.comments = result;
      LYDataManager.share.updateLocalWorksData();
      setState(() {});
      EasyLoading.dismiss();
      Future.delayed(const Duration(milliseconds: 10)).then((value) {
        scrollview.jumpTo(scrollview.position.maxScrollExtent);
      });
    });
  }

  void _greatDidClick() {
    worksModel?.isGreat = !(worksModel?.isGreat ?? false);
    LYDataManager.share.updateLocalWorksData();
    setState(() {});
  }

  void _commentUpvoteDidClick(LYWorksCommentModel? model) {
    model?.isUpvote = !(model.isUpvote ?? false);
    setState(() {});
    LYDataManager.share.updateLocalWorksData();
  }

  void _voiceCommentDidClick(LYWorksCommentModel? model, int index) async {
    ;
    final isPlaying = LYVoicePlayer().isPlaying;
    debugPrint('=====$isPlaying===$currentPlayIndex=======');
    if (currentPlayIndex == index) {
      if (isPlaying) {
        await LYVoicePlayer().pausePlayer(true);
      }
      currentPlayIndex = -1;
      setState(() {});
    } else {
      if (isPlaying) {
        await LYVoicePlayer().pausePlayer(true);
      }
      final path = "${Config.applicationDirPath}/voices/${model?.content}";
      currentPlayIndex = index;
      setState(() {});
      LYVoicePlayer().startPlay(path, callBack:
          (bool isPlaying, String playPath, double currentPlaySecond) {
        debugPrint("---state-------$isPlaying---");
        if (!isPlaying) {
          currentPlayIndex = -1;
          setState(() {});
        }
      });
    }
  }

  void _moreButtonDidClick() {
    final title = userModel?.isFriend == true ? "Unfollow" : "Follow";
    final sheet = LYActionSheetPage(
      titles: [title, 'Block', 'Report'],
      onTap: (type) {
        if (type == 0) {
          _followDidClick();
        } else if (type == 1) {
          _blockDidClick();
        } else if (type == 2) {
          _reportDidClick();
        }
      },
    );
    Get.dialog(sheet, useSafeArea: false);
  }

  void _followDidClick() async {
    EasyLoading.show();
    if (userModel?.isFriend == true) {
      final response = await HttpUtils.getInstance
          .post(URLApi.unfriend, data: {'followUserId': userModel?.userId});
      userModel?.isFriend = !(userModel?.isFriend ?? false);
      EasyLoading.dismiss();
      EasyLoading.showToast('Unfollow successfully');
    } else {
      final response = await HttpUtils.getInstance
          .post(URLApi.addFriend, data: {'followUserId': userModel?.userId});
      userModel?.isFriend = !(userModel?.isFriend ?? false);
      EasyLoading.dismiss();
      EasyLoading.showToast('Follow successfully.');
    }
    LYDataManager.share.updateUserInfo();
    setState(() {});
  }

  void _blockDidClick() async {
    EasyLoading.show();
    await LYDataManager.share.blackUser(userModel?.userId);
    EasyLoading.dismiss();
    EasyLoading.showToast("Blocked successfully");
    Future.delayed(const Duration(seconds: 2)).then((value) {
      Get.back();
    });
  }

  void _reportDidClick() {
    final titles = [
      'Pornographic',
      'False gender',
      'Fraud',
      'Political sensitive',
      'Other'
    ];
    final sheet = LYActionSheetPage(
      titles: titles,
      onTap: (index) {
        _submitReport(titles[index], "Report", worksModel?.userId)
            .then((value) {
          EasyLoading.showToast('Report Successfully');
        });
      },
    );
    Get.dialog(sheet, useSafeArea: false);
  }

  Future<void> _submitReport(String complainSub, String complainCategory,
      String? broadcasterId) async {
    EasyLoading.show();
    Map<String, String> parameters = {
      'broadcasterId': broadcasterId ?? '',
      'complainSub': complainSub,
      'complainCategory': complainCategory
    };
    final response = await HttpUtils.getInstance
        .post(URLApi.insertBlockRecord, data: parameters);
    EasyLoading.dismiss();
  }

  @override
  Widget build(BuildContext context) {
    final String avatar;
    if (worksModel?.isSave == true) {
      avatar =
          LYLoginInfoManager.getInstance.loginModel?.userInfo?.avatarUrl ?? '';
    } else {
      avatar = worksModel?.avatar ?? '';
    }
    return Material(
      child: Stack(
        children: [
          Positioned.fill(
              child: Scaffold(
            appBar: AppBar(
              title: Row(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Container(
                      width: 34,
                      height: 34,
                      margin: const EdgeInsets.only(right: 12),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(12),
                        border:
                            Border.all(color: AppColors.whiteColor, width: 2),
                      ),
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(12),
                        child: CachedNetworkImage(
                          imageUrl: avatar,
                          width: 34,
                          height: 34,
                        ),
                      )),
                  Flexible(
                    child: Text(
                      worksModel?.nickname ?? '',
                      overflow: TextOverflow.clip,
                      softWrap: true,
                      maxLines: 1,
                      style: const TextStyle(
                          fontSize: 16,
                          color: AppColors.color202020,
                          overflow: TextOverflow.clip),
                    ),
                  ),
                  InkWell(
                    onTap: () => _followDidClick(),
                    child: Padding(
                      padding: const EdgeInsets.only(left: 10),
                      child: Image.asset(
                        'assets/images/user_page_love_${userModel?.isFriend == true ? "h" : "n"}.png',
                        width: 24,
                        height: 24,
                      ),
                    ),
                  ),
                ],
              ),
              actions: [
                IconButton(
                    padding: const EdgeInsets.only(right: 20),
                    onPressed: () {
                      _moreButtonDidClick();
                    },
                    icon: Image.asset(
                      'assets/images/more_h_icon.png',
                      width: 28,
                      height: 28,
                    ))
              ],
              backgroundColor: AppColors.colorD7FFDF,
              leading: InkWell(
                child: Image.asset(
                  'assets/images/back_icon.png',
                  width: 24,
                  height: 24,
                ),
                onTap: () {
                  Get.close(0);
                },
              ),
              elevation: 0,
            ),
            backgroundColor: AppColors.whiteColor,
            body: SafeArea(
              child: Container(
                color: AppColors.colorF8FDEE,
                child: Stack(
                  fit: StackFit.expand,
                  children: [
                    _makeImagesWidget(),
                    Positioned(
                        top: 207,
                        left: 0,
                        right: 0,
                        bottom: 0,
                        child: _makeContent()),
                    Positioned(
                        left: 0,
                        right: 0,
                        bottom: 0,
                        height: 70,
                        child: _makeInputWidget()),
                  ],
                ),
              ),
            ),
            resizeToAvoidBottomInset: true,
          )),
          Positioned.fill(
              child: Visibility(
                  visible: isRecordPageVisible,
                  child: LYVoiceRecorderPage(
                    isRecording: isRecording,
                  ))),
        ],
      ),
    );
  }

  Widget _makeInputWidget() {
    return Container(
      padding: const EdgeInsets.only(left: 20, right: 20),
      alignment: Alignment.centerLeft,
      height: 70,
      decoration: const BoxDecoration(
        borderRadius: BorderRadius.only(
            topRight: Radius.circular(12), topLeft: Radius.circular(12)),
        color: AppColors.whiteColor,
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          InkWell(
            onTap: () => _voiceTextExchangeDidClick(),
            child: Image.asset(
              'assets/images/${isUseVoice ? 'keyboard_icon.png' : 'voice_icon.png'}',
              width: 32,
              height: 32,
            ),
          ),
          Expanded(
            child: isUseVoice ? _makeVoiceWidget() : _makeTextFieldWidget(),
          ),
          InkWell(
            onTap: () => _sendButtonDidClick(),
            child: Container(
              alignment: Alignment.center,
              width: 63,
              height: 32,
              decoration: BoxDecoration(
                  gradient: const LinearGradient(
                      colors: [AppColors.colorCCFF78, AppColors.color78FF85]),
                  borderRadius: BorderRadius.circular(16)),
              child: const Text(
                'Send',
                style: TextStyle(color: AppColors.color404040, fontSize: 16),
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _makeTextFieldWidget() {
    return Container(
      margin: const EdgeInsets.only(left: 24, right: 24),
      height: 40,
      width: double.infinity,
      alignment: Alignment.centerLeft,
      // padding: const EdgeInsets.only(top: 12, bottom: 12, right: 12),
      decoration: BoxDecoration(
        color: AppColors.colorF2F2F2,
        borderRadius: BorderRadius.circular(15),
      ),
      child: TextField(
        focusNode: _focusNode,
        textAlign: TextAlign.start,
        controller: textController,
        style: const TextStyle(fontSize: 15, color: AppColors.color202020),
        decoration: InputDecoration(
          contentPadding: const EdgeInsets.only(
            left: 12,
          ),
          hintText: "Enter your ideas...",
          hintStyle: TextStyle(
              fontSize: 10, color: colorWithRGBA(r: 0, g: 0, b: 0, a: 0.3)),
          enabledBorder: InputBorder.none,
          disabledBorder: InputBorder.none,
          focusedBorder: InputBorder.none,
          border: InputBorder.none,
          filled: true,
          fillColor: AppColors.colorF2F2F2,
          isDense: true,
          isCollapsed: true,
        ),
      ),
    );
  }

  Widget _makeVoiceWidget() {
    return GestureDetector(
      onTapDown: (detail) {
        _recordButtonTapDown();
      },
      onPanUpdate: (detail) {
        isRecording = detail.localPosition.dy > -80;
        setState(() {});
      },
      onPanEnd: (detail) {
        debugPrint('========onPanEnd===========');
        isRecordPageVisible = false;
        setState(() {});
        _didFinishRecord(isRecording);
      },
      onTapUp: (detail) {
        debugPrint('========onTapUp===========');
        isRecordPageVisible = false;
        setState(() {});
        _didFinishRecord(isRecording);
      },
      child: Container(
        margin: const EdgeInsets.only(left: 24, right: 24),
        height: 40,
        alignment: Alignment.center,
        decoration: BoxDecoration(
            color: AppColors.colorD7FFDF,
            borderRadius: BorderRadius.circular(12)),
        child: const Text(
          'Hold and speak',
          style: TextStyle(fontSize: 12, color: AppColors.color457E0D),
        ),
      ),
    );
  }

  Widget _makeContent() {
    return CustomScrollView(
      controller: scrollview,
      slivers: [
        SliverToBoxAdapter(
          child: Container(
            margin: const EdgeInsets.only(left: 16, right: 16),
            padding:
                const EdgeInsets.only(left: 20, right: 20, top: 32, bottom: 20),
            decoration: const BoxDecoration(
              image: DecorationImage(
                image: AssetImage('assets/images/works_detail_content_bg.png'),
                fit: BoxFit.fill,
              ),
            ),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisSize: MainAxisSize.min,
              children: [
                Text(
                  worksModel?.title ?? '',
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                  style: const TextStyle(
                      color: AppColors.color202020, fontSize: 16),
                ),
                const SizedBox(
                  height: 16,
                ),
                Text(
                  translateContent.isNotEmpty
                      ? translateContent
                      : worksModel?.description ?? '',
                  maxLines: 1000,
                  overflow: TextOverflow.ellipsis,
                  style: const TextStyle(
                      color: AppColors.color454545, fontSize: 13),
                ),
                Container(
                  padding: const EdgeInsets.only(top: 24),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      InkWell(
                        onTap: () => _translateButtonDidClick(),
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          mainAxisSize: MainAxisSize.min,
                          children: [
                            Image.asset(
                              'assets/images/works_content_translate_icon.png',
                              width: 16,
                              height: 16,
                            ),
                            const SizedBox(
                              width: 7,
                            ),
                            const Text(
                              'Translate',
                              style: TextStyle(
                                  color: AppColors.color999999, fontSize: 10),
                            )
                          ],
                        ),
                      ),
                      InkWell(
                        onTap: () => _greatDidClick(),
                        child: Image.asset(
                          'assets/images/great_icon_${worksModel?.isGreat == true ? "h" : "n"}.png',
                          width: 34,
                          height: 34,
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),
        SliverToBoxAdapter(
          child: Container(
            padding: const EdgeInsets.only(top: 24, bottom: 16, left: 16),
            child: Text(
              'Comment（${worksModel?.comments?.length ?? 0}）',
              style: const TextStyle(
                  color: AppColors.color202020,
                  fontSize: 16,
                  fontWeight: FontWeight.bold),
            ),
          ),
        ),
        _makeCommentsList(),
      ],
    );
  }

  Widget _makeCommentsList() {
    return SliverPadding(
      padding: const EdgeInsets.only(left: 16, right: 16, bottom: 80),
      sliver: SliverList(
          delegate: SliverChildBuilderDelegate(
        (context, index) {
          final model = worksModel?.comments?[index];
          if (model?.type == 1) {
            return _makeVoiceCommentWidget(model, index);
          }
          return _makeTextCommentWidget(model);
        },
        childCount: worksModel?.comments?.length ?? 0,
      )),
    );
  }

  Widget _makeTextCommentWidget(LYWorksCommentModel? model) {
    return Container(
      padding: const EdgeInsets.all(16),
      margin: const EdgeInsets.only(bottom: 12),
      decoration: BoxDecoration(
          color: AppColors.whiteColor, borderRadius: BorderRadius.circular(16)),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.stretch,
        mainAxisSize: MainAxisSize.min,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              ClipRRect(
                  borderRadius: BorderRadius.circular(19),
                  child: CachedNetworkImage(
                    imageUrl: model?.avatar ?? '',
                    width: 38,
                    height: 38,
                  )),
              const SizedBox(
                width: 10,
              ),
              Expanded(
                child: Text(
                  model?.nickname ?? '',
                  style: const TextStyle(
                      color: AppColors.color404040,
                      fontSize: 14,
                      fontWeight: FontWeight.bold),
                ),
              ),
              InkWell(
                onTap: () => _commentUpvoteDidClick(model),
                child: Image.asset(
                  'assets/images/great_icon_${model?.isUpvote == true ? "h" : "n"}.png',
                  width: 34,
                  height: 34,
                ),
              ),
            ],
          ),
          Container(
            padding: const EdgeInsets.only(top: 12),
            child: Text(
              model?.content ?? '',
              maxLines: 1000,
              style:
                  const TextStyle(color: AppColors.color404040, fontSize: 12),
            ),
          ),
        ],
      ),
    );
  }

  Widget _makeVoiceCommentWidget(LYWorksCommentModel? model, int index) {
    return Container(
      height: 120,
      padding: const EdgeInsets.all(16),
      margin: const EdgeInsets.only(bottom: 12),
      decoration: BoxDecoration(
          color: AppColors.whiteColor, borderRadius: BorderRadius.circular(16)),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisSize: MainAxisSize.min,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              ClipRRect(
                  borderRadius: BorderRadius.circular(19),
                  child: CachedNetworkImage(
                    imageUrl: model?.avatar ?? '',
                    width: 38,
                    height: 38,
                  )),
              const SizedBox(
                width: 10,
              ),
              Expanded(
                child: Text(
                  model?.nickname ?? '',
                  style: const TextStyle(
                      color: AppColors.color404040,
                      fontSize: 14,
                      fontWeight: FontWeight.bold),
                ),
              ),
              InkWell(
                onTap: () => _commentUpvoteDidClick(model),
                child: Image.asset(
                  'assets/images/great_icon_${model?.isUpvote == true ? "h" : "n"}.png',
                  width: 34,
                  height: 34,
                ),
              ),
            ],
          ),
          InkWell(
            onTap: () {
              _voiceCommentDidClick(model, index);
            },
            child: Container(
              height: 28,
              margin: const EdgeInsets.only(top: 14, left: 64),
              padding: const EdgeInsets.only(left: 20, right: 20),
              decoration: BoxDecoration(
                  gradient: const LinearGradient(
                      colors: [AppColors.colorCCFF78, AppColors.color78FF85]),
                  borderRadius: BorderRadius.circular(14)),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisSize: MainAxisSize.min,
                children: [
                  SizedBox(
                    width: 16,
                    height: 16,
                    child: currentPlayIndex == index
                        ? const SVGASimpleImage(
                            assetsName: 'assets/svgas/speak_voice.svga',
                          )
                        : Image.asset('assets/images/speak_icon.png'),
                  ),
                  const SizedBox(
                    width: 8,
                  ),
                  Text(
                    '${model?.seconds ?? 0}s',
                    style: const TextStyle(
                        color: AppColors.color202020, fontSize: 16),
                  )
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _makeImagesWidget() {
    return Positioned(
        top: 0,
        left: 0,
        right: 0,
        height: 230,
        child: Swiper(
          controller: swiperController,
          itemCount: worksModel?.images?.length ?? 0,
          autoplay: true,
          autoplayDelay: 10000,
          loop: true,
          itemBuilder: (context, index) {
            final imageName = worksModel?.images?[index];
            if (worksModel?.isSave == true) {
              return Image.file(
                File("${Config.applicationDirPath}/${imageName ?? ''}"),
                height: 230,
                fit: BoxFit.cover,
              );
            }
            return Image.asset(
              'assets/images/works_images/$imageName',
              height: 230,
              fit: BoxFit.cover,
            );
          },
          pagination: SwiperPagination(
              margin: const EdgeInsets.only(bottom: 30),
              builder: LYRectSwiperPaginationBuilder(
                  activeColor: AppColors.color78FF85,
                  color: AppColors.colorCCCCCC,
                  size: const Size(4, 4),
                  space: 5.px,
                  activeSize: const Size(8, 4))),
        ));
  }

  @override
  void dispose() {
    EasyLoading.dismiss();
    textController.dispose();
    swiperController.dispose();
    super.dispose();
  }
}
